package com.example.android2019.ch3;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.annotation.Nullable;
import android.util.Log;

/**
 * Created by 一世长安一世欢 on 2019/5/31.
 */

public class MyHelper extends SQLiteOpenHelper {
    public MyHelper(Context context) {
        super(context, "p.db", null, 3);
        Log.v("sqlite", "构造方法");
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "create table user(id integer primary key autoincrement,name varchar(20))";
        db.execSQL(sql);
        Log.v("sqlie", "onCreate方法");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        String sql = "alter table user add sex char(5)";
        db.execSQL(sql);
        Log.v("sqlite", "onUpgrade方法");
    }
}
